-- thrown knife

if SERVER then
   AddCSLuaFile("shared.lua")
else

end

ENT.PrintName = "Gore Test"
ENT.Author			= "Devcon"
ENT.Information		= "Gore test"
ENT.Category		= "Fun + Games"

ENT.Editable		= true
ENT.Spawnable		= true
ENT.AdminOnly		= false

ENT.Type = "anim"
ENT.Gibs = 5
ENT.SpawnRadius = 50
ENT.MinVelocity = -500
ENT.MaxVelocity = 500
ENT.GibGravity = 1
ENT.GibModel = Model("models/props_junk/Rock001a.mdl")

ENT.ImpactSounds = {
	-- Sound("devin/blackbetty/player/body_impact/body_medium_impact_hard1.wav"),
	-- Sound("devin/blackbetty/player/body_impact/body_medium_impact_hard2.wav"),
	-- Sound("devin/blackbetty/player/body_impact/body_medium_impact_hard3.wav"),
	-- Sound("devin/blackbetty/player/body_impact/body_medium_impact_hard4.wav"),
	-- Sound("devin/blackbetty/player/body_impact/body_medium_impact_hard5.wav"),
	-- Sound("devin/blackbetty/player/body_impact/body_medium_impact_hard6.wav")
	Sound("physics/flesh/flesh_impact_bullet1.wav"),
	Sound("physics/flesh/flesh_impact_bullet2.wav"),
	Sound("physics/flesh/flesh_impact_bullet3.wav"),
	Sound("physics/flesh/flesh_impact_bullet4.wav"),
	Sound("physics/flesh/flesh_impact_bullet5.wav")
}

ENT.GibModels = {
	Model("models/quakegibs/quakemdl/abdomen.mdl"),
	Model("models/quakegibs/quakemdl/arm.mdl"),
	Model("models/quakegibs/quakemdl/brain.mdl"),
	Model("models/quakegibs/quakemdl/chest.mdl"),
	Model("models/quakegibs/quakemdl/fist.mdl"),
	Model("models/quakegibs/quakemdl/foot.mdl"),
	Model("models/quakegibs/quakemdl/forearm.mdl"),
	Model("models/quakegibs/quakemdl/intestine.mdl"),
	Model("models/quakegibs/quakemdl/leg.mdl"),
	Model("models/quakegibs/quakemdl/skull.mdl"),
}


if SERVER then

	function ENT:Initialize()
		self:SetRenderMode(RENDERMODE_NONE)
		self:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
		self:SetSolid(SOLID_VPHYSICS)
		self:SetMoveType(MOVETYPE_NONE)
		self:SetModel(self.GibModels[math.random(1, #self.GibModels)])
	end
	
	function ENT:SetMode(mode)
		if(mode == "gib")then
			self:Gib()
		elseif(mode == "smallhit")then
			self:SmallHit()
		elseif(mode == "bighit")then
			self:BigHit()
		end
		timer.Simple(RESPAWN_TIME or 5, function() self:Remove() end)
	end
	
	function ENT:Gib()
		for i = 1, #self.GibModels, 1 do
			local gib = ents.Create("gore_giblet")
			gib:Initialize();
			gib:SetMode("big")
			gib:SetModel(self.GibModels[i])
			gib:SetPos(self:GetPos() + Vector(0, 0, 8))
		end
	end
	
	function ENT:SmallHit()
		local gib = ents.Create("gore_giblet")
		gib:Initialize();
		gib:SetMode("big")
		gib:SetModel(self.GibModels[math.random(1, #self.GibModels)])
		gib:SetPos(self:GetPos() + Vector(0, 0, 8))
	end
	
	function ENT:BigHit()
		for i = 1, 3, 1 do
			local gib = ents.Create("gore_giblet")
			gib:Initialize();
			gib:SetMode("big")
			gib:SetModel(self.GibModels[math.random(1, #self.GibModels)])
			gib:SetPos(self:GetPos() + Vector(0, 0, 8))
			gib.MaxBounces = 3
		end
	end


end


